package convertedores;

import entidades.Processo;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import rn.ProcessoRN;

/**
 *
 * @author Marcelo Gomes Neto
 */
public class ConverteIDtoPag implements Converter 
{

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String idProcesso) {
        return (Object)idProcesso;
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) 
    {
        String pag = null;
        try 
        {
            Integer id = (Integer)o;
            ProcessoRN processoRN = new ProcessoRN();
            Processo processo = processoRN.carregarProcesso(id);
            pag = processo.getPag();
            return pag;
        } 
        catch (Exception ex) {
            Logger.getLogger(ConverteIDtoPag.class.getName()).log(Level.SEVERE, null, ex);
        }
        return pag;
    }
}